#ifndef MONITORDEVICE_H
#define MONITORDEVICE_H

#include <QMainWindow>
#include"usermysqls.h"
namespace Ui {
class MonitorDevice;//监测传感器数据的类
}
 struct SensorThresholdData
{
int id;
QString sensorName;
int alarmUpperLimit;
int alarmLowerLimit;
QString alarmUpperLimitHappend;
QString alarmLowerLimitHappend;
};
struct sensorDataStatus{

int airT;
int airH;
int Light;
int CO2;
int soilH;
};
class sensorData;
class MonitorDevice : public QMainWindow
{
    Q_OBJECT

public:
    explicit MonitorDevice(QWidget *parent = nullptr);
    ~MonitorDevice();
   static MonitorDevice* instance();
    void MonitorSensorDataFunction(const sensorData &Data);//监测传感器数组函数
   private slots:
void receiveAutoControlSignal(int status);

private:
    bool getSensorThresholdData(QVector<SensorThresholdData> &thresholdData);//从数据库来获取传感器的报警上限下限值
    void initSensorDataStatus(sensorDataStatus& Data);
    bool getAutoControlStatus();
signals:
    void sendAirTemperature(int status);//true为过高，false为过低 -1为过低 1为过高 0为正常//手动控制


    void sendAirHumidity(int status);

    void sendLightIntensity(int status);

    void sendCO2Concentration(int status);

    void sendSoilMoisture(int status);
    void sendWarningLed(bool ok);
    void sendAirTemperatureToWarningInformation(int index,int status);
    void sendAirHumidityToWarningInformation(int index,int status);
    void sendLightIntensityToWarningInformation(int index,int status);
    void sendCO2ConcentrationToWarningInformation(int index,int status);
    void sendSoilMoistureToWarningInformation(int index,int status);
//自动控制各设备
    void sendAutoControlAirTemperature(int status);

    void sendAutoControlAirHumidity(int status);

    void sendAutoControlLightIntensity(int status);

    void sendAutoControlCO2Concentration(int status);

    void sendAutoControlSoilMoisture(int status);


private:
    Ui::MonitorDevice *ui;
    QVector<SensorThresholdData> thresholdData;
    sensorDataStatus SensorDataStatus;
    bool autoControlStatus=true;
};

#endif // MONITORDEVICE_H
